package com.yang.controller.wx;

import com.yang.bean.MarketGoods;
import com.yang.bean.MarketUser;
import com.yang.bean.common.BaseParam;
import com.yang.bean.common.BaseRespVo;
import com.yang.bean.common.CommonData;
import com.yang.bean.zdd.bo.DeleteFootPrintBo;
import com.yang.exception.WXException;
import com.yang.service.wx.WXFootprintService;
import com.yang.utils.UserUtil;
import org.apache.shiro.session.Session;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName WXFootprintController
 * @Description TODO
 * @Author zhangdongdong
 * @Date 2022/9/11 20:21
 * @Version 1.0
 */
@RestController
@RequestMapping("wx/footprint")
public class WXFootprintController {
    @Autowired
    WXFootprintService wxFootprintService;

    @Autowired
    DefaultWebSessionManager defaultWebSessionManager;

    @RequestMapping("list")
    public BaseRespVo list(BaseParam info, HttpServletRequest request) {
        MarketUser marketUser = UserUtil.getUserMsg(request, defaultWebSessionManager);

        CommonData<MarketGoods> data = wxFootprintService.list(info, marketUser.getId());

        return BaseRespVo.ok(data);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody DeleteFootPrintBo footPrintBo) {
        wxFootprintService.delete(footPrintBo.getId());
        return BaseRespVo.ok();
    }
}
